
import { _decorator, Component, Node } from 'cc';
import { Hp } from './Hp';
import { DamageStruct } from '../FightControl';
import EvtManger from '../../tools/EvtManger';
import { EventName } from '../../manager/AppControll';
const { ccclass, property } = _decorator;


@ccclass('BossHp')
export class BossHp extends Hp {
    protected onLoad(): void {

    }

    InitHp(maxHp: number): void {
        super.InitHp(maxHp);
    }

    public takeDamage(damageS: DamageStruct) {
        if (!this.progressBar) return;
        this.PlaySubtractHealth(damageS)
        this._curHP -= damageS.damage;
        if (this._curHP < 0) {
            this._curHP = 0;
        }
        if (this._curHP <= 0) {
            this.onDeath();
        }
        EvtManger.do(EventName.showBossHp, this._curHP / this._maxHP)
    }


    PlaySubtractHealth(damageS: DamageStruct) {
        super.PlaySubtractHealth(damageS);
    }

    protected onDeath() {
        super.onDeath();
    }

}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
